package com.info.zhiduoduo.admin.controller;

import com.info.zhiduoduo.admin.model.formbean.commonproblem.CommonProblemFormBean;
import com.info.zhiduoduo.admin.model.formbean.commonproblem.GetCommonProblemFormBean;
import com.info.zhiduoduo.admin.model.formbean.commonproblem.UpdateCommonProblemFormBean;
import com.info.zhiduoduo.admin.service.CommonProblemService;
import com.info.zhiduoduo.common.constants.SmartResult;
import com.info.zhiduoduo.common.formbean.BaseSimpleFormBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Trink丶
 */
@Api(tags = "常见问题Q&A")
@RestController
@RequestMapping("/commonProblem")
public class CommonProblemController {

    @Autowired
    private CommonProblemService commonProblemService;

    @ApiOperation("增加常见问题")
    @PostMapping("/saveCommonProblem")
    public SmartResult saveCommonProblem(@RequestBody BaseSimpleFormBean<CommonProblemFormBean> formBean) {
        return commonProblemService.saveCommonProblem(formBean);
    }

    @ApiOperation("修改常见问题")
    @PostMapping("/updateCommonProblem")
    public SmartResult updateCommonProblem(@RequestBody BaseSimpleFormBean<UpdateCommonProblemFormBean> formBean) {
        return commonProblemService.updateCommonProblem(formBean);
    }

    @ApiOperation("删除常见问题")
    @PostMapping("/deleteCommonProblem")
    public SmartResult deleteCommonProblem(@RequestBody BaseSimpleFormBean<Integer> formBean) {
        return commonProblemService.deleteCommonProblem(formBean);
    }

    @ApiOperation("批量删除常见问题")
    @PostMapping("/deleteCommonProblemList")
    public SmartResult deleteCommonProblemList(@RequestBody BaseSimpleFormBean<List<Integer>> formBean) {
        return commonProblemService.deleteCommonProblemList(formBean);
    }

    @ApiOperation("查询常见问题")
    @PostMapping("/getCommonProblemList")
    public SmartResult getCommonProblemList(@RequestBody BaseSimpleFormBean<GetCommonProblemFormBean> formBean) {
        return commonProblemService.getCommonProblemList(formBean);
    }
}
